
# wlsdk 依赖其他模块，所以需要增加所有这些模块的头文件目录
set(link_libs_inc ${CMAKE_CURRENT_SOURCE_DIR}/ ${CMAKE_CURRENT_SOURCE_DIR}/src)
foreach(_lib ${link_libs})
    get_target_property(LIB_INC ${_lib} INCLUDE_DIRECTORIES)
    list(APPEND link_libs_inc ${LIB_INC})
endforeach()
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src wlsdk_src)
add_library(wlsdk STATIC ${wlsdk_src})

if (${USING_EXTERNAL_OPUS})
    target_compile_definitions(wlsdk PRIVATE WL_USING_EXT_OPUS)
endif()    

target_include_directories(wlsdk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${link_libs_inc})
target_include_directories(wlsdk PUBLIC
            ${CMAKE_CURRENT_SOURCE_DIR}/
            ${CMAKE_CURRENT_SOURCE_DIR}/src)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../../include DESTINATION ${CMAKE_BINARY_DIR}/ FOLLOW_SYMLINK_CHAIN)

# 把所有生成得东西单独拷贝到一个目录去
if (NOT EXISTS ${CMAKE_BINARY_DIR}/sdk_release)
        file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/sdk_release)
        file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/sdk_release/inc)
        file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/sdk_release/lib)
        file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/sdk_release/ext_inc)

        if (${USE_WLSDK_TEST})
            file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/test/sdk_release)
            file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/test/sdk_release/inc)
            file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/test/sdk_release/lib)
        endif()
endif()

file(REMOVE ${CMAKE_BINARY_DIR}/sdk_release/inc/*.*)
file(COPY ${CMAKE_BINARY_DIR}/include/wl_types.h DESTINATION ${CMAKE_BINARY_DIR}/sdk_release/inc FOLLOW_SYMLINK_CHAIN)
file(COPY ${CMAKE_BINARY_DIR}/include/wlsdk_define.h DESTINATION ${CMAKE_BINARY_DIR}/sdk_release/inc FOLLOW_SYMLINK_CHAIN)
file(COPY ${CMAKE_BINARY_DIR}/include/wlsdk.h DESTINATION ${CMAKE_BINARY_DIR}/sdk_release/inc FOLLOW_SYMLINK_CHAIN)
file(GLOB ext_files "${CMAKE_BINARY_DIR}/include/external/*")
file(COPY ${ext_files} DESTINATION ${CMAKE_BINARY_DIR}/sdk_release/ext_inc FOLLOW_SYMLINK_CHAIN)

if (${USE_WLSDK_TEST})
    file(REMOVE ${CMAKE_SOURCE_DIR}/test/sdk_release/inc/*.*)
    file(COPY ${CMAKE_BINARY_DIR}/include/wl_types.h DESTINATION ${CMAKE_SOURCE_DIR}/test/sdk_release/inc FOLLOW_SYMLINK_CHAIN)
    file(COPY ${CMAKE_BINARY_DIR}/include/wlsdk_define.h DESTINATION ${CMAKE_SOURCE_DIR}/test/sdk_release/inc FOLLOW_SYMLINK_CHAIN)
    file(COPY ${CMAKE_BINARY_DIR}/include/wlsdk.h DESTINATION ${CMAKE_SOURCE_DIR}/test/sdk_release/inc FOLLOW_SYMLINK_CHAIN)
endif()



